import request from '@/utils/request'

/**
 * 获取合同审核列表
 * @param {Object} params 查询参数
 */
export function getContractReviewList(params) {
  return request({
    url: '/api/contracts/review',
    method: 'get',
    params
  })
}

/**
 * 根据ID获取合同详情
 * @param {Number} id 合同ID
 */
export function getContractById(id) {
  return request({
    url: `/api/contracts/${id}`,
    method: 'get'
  })
}

/**
 * 审核通过合同
 * @param {Number} id 合同ID
 * @param {String} remark 审核备注
 */
export function approveContract(id, remark = '') {
  return request({
    url: `/api/contracts/${id}/approve`,
    method: 'post',
    data: { remark }
  })
}

/**
 * 拒绝合同
 * @param {Number} id 合同ID
 * @param {String} reason 拒绝原因
 */
export function rejectContract(id, reason) {
  return request({
    url: `/api/contracts/${id}/reject`,
    method: 'post',
    data: { reason }
  })
}

/**
 * 删除合同
 * @param {Number} id 合同ID
 */
export function deleteContract(id) {
  return request({
    url: `/api/contracts/${id}`,
    method: 'delete'
  })
}

/**
 * 批量删除合同
 * @param {Array} ids 合同ID数组
 */
export function batchDeleteContracts(ids) {
  return request({
    url: '/api/contracts/batch-delete',
    method: 'post',
    data: { ids }
  })
}

/**
 * 生成合同PDF
 * @param {Number} id 合同ID
 */
export function generateContractPDF(id) {
  return request({
    url: `/api/contracts/${id}/pdf`,
    method: 'get',
    responseType: 'blob'
  })
}

/**
 * 导出合同数据
 * @param {Object} params 查询参数
 */
export function exportContracts(params) {
  return request({
    url: '/api/contracts/export',
    method: 'get',
    params,
    responseType: 'blob'
  })
} 